/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package BL;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;

/**
 *
 * @author sundas
 */
@Entity
@Table(name = "price", catalog = "newPurchase", schema = "", uniqueConstraints = {@UniqueConstraint(columnNames = {"priceVariationId", "productNumber"})})
@NamedQueries({@NamedQuery(name = "Price.findAll", query = "SELECT p FROM Price p"), @NamedQuery(name = "Price.findByPriceVariationId", query = "SELECT p FROM Price p WHERE p.pricePK.priceVariationId = :priceVariationId"), @NamedQuery(name = "Price.findByPriceVariationDate", query = "SELECT p FROM Price p WHERE p.priceVariationDate = :priceVariationDate"), @NamedQuery(name = "Price.findByPriceVariationEffe", query = "SELECT p FROM Price p WHERE p.priceVariationEffe = :priceVariationEffe"), @NamedQuery(name = "Price.findByPriceVariationStat", query = "SELECT p FROM Price p WHERE p.priceVariationStat = :priceVariationStat"), @NamedQuery(name = "Price.findByProductNumber", query = "SELECT p FROM Price p WHERE p.pricePK.productNumber = :productNumber")})
public class Price implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected PricePK pricePK;
    @Basic(optional = false)
    @Column(name = "priceVariationDate", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date priceVariationDate;
    @Basic(optional = false)
    @Column(name = "priceVariationEffe", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date priceVariationEffe;
    @Basic(optional = false)
    @Column(name = "priceVariationStat", nullable = false, length = 10)
    private String priceVariationStat;
    @JoinColumn(name = "productNumber", referencedColumnName = "productNumber", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Product product;

    public Price() {
    }

    public Price(PricePK pricePK) {
        this.pricePK = pricePK;
    }

    public Price(PricePK pricePK, Date priceVariationDate, Date priceVariationEffe, String priceVariationStat) {
        this.pricePK = pricePK;
        this.priceVariationDate = priceVariationDate;
        this.priceVariationEffe = priceVariationEffe;
        this.priceVariationStat = priceVariationStat;
    }

    public Price(int priceVariationId, int productNumber) {
        this.pricePK = new PricePK(priceVariationId, productNumber);
    }

    public PricePK getPricePK() {
        return pricePK;
    }

    public void setPricePK(PricePK pricePK) {
        this.pricePK = pricePK;
    }

    public Date getPriceVariationDate() {
        return priceVariationDate;
    }

    public void setPriceVariationDate(Date priceVariationDate) {
        this.priceVariationDate = priceVariationDate;
    }

    public Date getPriceVariationEffe() {
        return priceVariationEffe;
    }

    public void setPriceVariationEffe(Date priceVariationEffe) {
        this.priceVariationEffe = priceVariationEffe;
    }

    public String getPriceVariationStat() {
        return priceVariationStat;
    }

    public void setPriceVariationStat(String priceVariationStat) {
        this.priceVariationStat = priceVariationStat;
    }

    public Product getProduct() {
        return product;
    }

    public void setProduct(Product product) {
        this.product = product;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (pricePK != null ? pricePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Price)) {
            return false;
        }
        Price other = (Price) object;
        if ((this.pricePK == null && other.pricePK != null) || (this.pricePK != null && !this.pricePK.equals(other.pricePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "DB.Price[pricePK=" + pricePK + "]";
    }

}
